<?php
/**
 * Created by PhpStorm.
 * User: Ellon_Wong
 * Date: 14-4-25
 * Time: 下午10:28
 */
//include_once dirname(__FILE__) . '/../../lib/Log4PHP/Log4PHP.php';
include_once dirname(__FILE__) . '/../register/register_handle.php';
include_once dirname(__FILE__) . '/../login/login_handle.php';
include_once dirname(__FILE__) . '/../IngRecord/IngRecord_handle.php';
include_once dirname(__FILE__) . '/../generateResume/generateResume_handle.php';
include_once dirname(__FILE__) . '/../selectRecord/selectRecordHandle.php';
include_once dirname(__FILE__) . '/../common/common.php';
include_once dirname(__FILE__) . '/../common/dbConn.php';
include_once dirname(__FILE__) . '/../laws/laws_handle.php';
global $msgArray;
//global $log;

//$log = Log4PHP::getLogger("Server_go");


function Server_go($arg_body){
    try{
//        global $log;
        global $msgArray;
//        $log->info("===================Server_go begin=====================");
        if(!array_key_exists("route",$arg_body)){
            return MsgArray(404,"传入路由为空",[],"Warn");
        }
        $rsl = MsgArray(500,"操作失败！",[],"Warn");
        switch ($arg_body["route"]){
            case "register":$rsl=register_handler($arg_body);break;
            case "login":$rsl=login_handler($arg_body);break;
            case "addIngRecord":$rsl=addRecord_handler($arg_body);break;
            case "generateResume":$rsl=GenerateResume_handle($arg_body);break;
            case "selectRecord":$rsl=selectRecordHandle($arg_body);break;
            case "lawsSearch":$rsl=lawSear_handle($arg_body);break;
            default;break;
        }
        return $rsl;
    }catch (Exception $e){
//        $log->error("抛出异常:".$e->getMessage());
        return MsgArray(100001,"系统异常",[],"Error");
    }
}


//function register_func($arg_body){
//    try{
//        global $log;
//        global $msgArray;
//        $log->info("===================register_func begin=====================");
//        $log->info("传入参数：");
//        $log->info($arg_body);
//        if(!array_key_exists("userAccount",$arg_body)){
//            return MsgArray(false,"传入用户名为空",[],"Warn");
//        }
//
//        if(!array_key_exists("userPassword",$arg_body)){
//            return MsgArray(false,"传入密码为空",[],"Warn");
//        }
//
//        $rsl = MsgArray(false,"操作失败!",[],"Warn");
//
//        $q_pdo=connectDatabase();
//        if(null==$q_pdo){
//            return MsgArray(false,"数据库连接异常",[],"Warn");
//        }
//        $q_pdo->beginTransaction();
//        $reg_sql = "INSERT INTO T_USER (U_ACCOUNT,U_PASSWORD,U_STATUS) VALUES (?,?,?)";
//
//        $log->info($reg_sql);
//        $stmt = $q_pdo->prepare($reg_sql);
//        $num=$stmt->execute(array($arg_body["userAccount"],$arg_body["userPassword"],"active"));
//        if($num<=0){
//            return MsgArray(false,"插入注册数据失败！","","Error");
//        }
//        $q_pdo->commit();
//        return MsgArray(true,"注册成功",[],"Success");
//
//    }catch (Exception $e){
//        $log->error("抛出异常:".$e->getMessage());
//        return MsgArray(100001,"系统异常",[],"Error");
//    }
//}

